package com.sl.biz.modular.restapi.dao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.biz.modular.restapi.dao.entity.ApiHeaderConfigDO;
import com.sl.biz.modular.restapi.dao.mapper.ApiHeaderConfigMapper;
import com.sl.biz.modular.restapi.dao.service.ApiHeaderConfigDaoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ApiHeaderConfigDaoServiceImpl extends ServiceImpl<ApiHeaderConfigMapper, ApiHeaderConfigDO> implements ApiHeaderConfigDaoService {
    @Override
    public Boolean removeByApiConfigId(String apiConfigId) {

        LambdaQueryWrapper<ApiHeaderConfigDO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ApiHeaderConfigDO::getApiId, apiConfigId);
        return super.remove(wrapper);
    }

    @Override
    public List<ApiHeaderConfigDO> queryByApiConfigId(String apiConfigId) {
        LambdaQueryWrapper<ApiHeaderConfigDO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ApiHeaderConfigDO::getApiId, apiConfigId);
        return super.list(wrapper);
    }

    @Override
    public List<ApiHeaderConfigDO> queryByVersionIdList(List<String> versionIdList) {
        LambdaQueryWrapper<ApiHeaderConfigDO> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(ApiHeaderConfigDO::getApiVersionId, versionIdList);
        return super.list(wrapper);
    }

    @Override
    public Boolean removeByApiVersionConfigId(String versionConfigId) {
        LambdaQueryWrapper<ApiHeaderConfigDO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ApiHeaderConfigDO::getApiVersionId, versionConfigId);
        return super.remove(wrapper);
    }
}
